package lee;

import java.util.Random;
import java.util.Scanner;

public class Code1 {
    public static void main(String[] args) {
        String line = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
        Random random = new Random();
        String code = "";
        for (int i =0;i<4;i++){
            int index = random.nextInt(line.length());
            char c = line.charAt(index);
            code+=c;
        }
        System.out.println("验证码为:"+code);
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入验证码:");
        String in = scanner.nextLine();
        if (code.equalsIgnoreCase(in)){
            System.out.println("验证成功");
        }else {
            System.out.println("验证失败");
        }

    }
}
